import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:yurun_smartmerchants/global.dart';
import 'package:yurun_smartmerchants/utils/app_size.dart';
import 'package:oktoast/oktoast.dart';
import 'package:qr_flutter/qr_flutter.dart';

class QrDialog extends Dialog {
  final String qrContent;
  final String name;


  QrDialog({this.name, this.qrContent});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: Material(
        type: MaterialType.transparency,
        child: GestureDetector(
          onTap: () {
            showToast('我是非遮罩区域');
          },
          child: Container(
            width: AppSize.width(580),
            height: AppSize.height(690),
            child: Stack(
              alignment: AlignmentDirectional.topCenter,
              children: <Widget>[
                Positioned(
                  top: AppSize.height(60),
                  child: Container(
                    decoration: ShapeDecoration(
                        color: Color(0xffEB4847),
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.only(
                                topLeft: Radius.circular(AppSize.height(5)),
                                topRight: Radius.circular(AppSize.height(5))))),
                    width: AppSize.width(580),
                    height: AppSize.height(150),
                  ),
                ),
                Positioned(
                    top: AppSize.height(145),
                    child: Text(name,
                        style: TextStyle(fontSize: 16, color: Colors.white))),
                Positioned(
                    top: AppSize.height(210),
                    child: Container(
                      alignment: Alignment.center,
                      decoration: ShapeDecoration(
                          color: Colors.white,
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.only(
                                  bottomLeft:
                                      Radius.circular(AppSize.height(5)),
                                  bottomRight:
                                      Radius.circular(AppSize.height(5))))),
                      width: AppSize.width(580),
                      height: AppSize.height(480),
                      child: qrContent == null ? Container() : Padding(padding: EdgeInsets.all(AppSize.height(30)),child: QrImage(
                        data: qrContent,
                      ),),
                    )),
                Positioned(
                    right: AppSize.height(2),
                    top: AppSize.height(60),
                    child: IconButton(
                        icon: Icon(
                          Icons.clear,
                          color: Colors.white,
                        ),
                        onPressed: () {
                          Navigator.pop(context);
                        })),
                Positioned(
                    child: Material(
                      shape: CircleBorder(
                          side: BorderSide(
                              color: Color(0xffEB4847), width: AppSize.width(7))),
                      child: Container(
                        width: AppSize.height(120),
                        height: AppSize.height(120),
                        child: ClipOval(
                          child: Image.network(Global.prefs.getString(Global.url_avatar),fit: BoxFit.cover,),
                        ),
                      ),
                )),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
